//
//  UILabel+Extension.swift
//  MYWeibo
//
//  Created by Magic Yu on 16/4/16.
//  Copyright © 2016年 Magic Yu. All rights reserved.
//

import UIKit

extension UILabel {

    //便利构造函数
    convenience init(text: String,textColor: UIColor,fontSize: CGFloat,margin: CGFloat = 0) {
        
        self.init()
        
        self.text = text
        self.textColor = textColor
        self.font = UIFont.systemFontOfSize(fontSize)
        self.textAlignment = .Center
        numberOfLines = 0
        //设置最大显示高度
        if margin > 0 {
        preferredMaxLayoutWidth = ScreenWidth - 2 * margin
            textAlignment = .Left
        }
        //自适应大小
        self.sizeToFit()
        
    }
}